/*     */ package com.zimbra.qa.unittest.prov.ldap;
/*     */ 
/*     */ import com.zimbra.common.account.Key.CosBy;
/*     */ import com.zimbra.common.util.StringUtil;
/*     */ import com.zimbra.cs.account.Cos;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ import org.junit.AfterClass;
/*     */ import org.junit.Assert;
/*     */ import org.junit.BeforeClass;
/*     */ import org.junit.Test;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class TestProvCallbackAvailableZimlets
/*     */   extends LdapTest
/*     */ {
/*  33 */   private static String COS_NAME = "cos1";
/*     */   private static LdapProvTestUtil provUtil;
/*     */   private static Provisioning prov;
/*     */   
/*     */   @BeforeClass
/*     */   public static void init() throws Exception {
/*  39 */     provUtil = new LdapProvTestUtil();
/*  40 */     prov = provUtil.getProv();
/*     */     
/*  42 */     Map<String, Object> attrs = new HashMap();
/*     */     
/*  44 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "foo");
/*  45 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "-foo");
/*  46 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "+foo");
/*  47 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "!foo");
/*  48 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "bar");
/*  49 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "-bar");
/*  50 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "+bar");
/*  51 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "!bar");
/*     */     
/*  53 */     Cos cos = prov.createCos(COS_NAME, attrs);
/*     */     
/*  55 */     Set<String> getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/*     */ 
/*  58 */     Assert.assertEquals(2L, getAttrs.size());
/*     */     
/*  60 */     Assert.assertTrue((getAttrs.contains("-foo")) || (getAttrs.contains("+foo")) || (getAttrs.contains("!foo")));
/*     */     
/*     */ 
/*     */ 
/*  64 */     Assert.assertTrue((getAttrs.contains("-bar")) || (getAttrs.contains("+bar")) || (getAttrs.contains("!bar")));
/*     */   }
/*     */   
/*     */   @AfterClass
/*     */   public static void cleanup()
/*     */     throws Exception
/*     */   {
/*  71 */     Cleanup.deleteAll(new String[] { baseDomainName() });
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testReplace() throws Exception {
/*  76 */     Cos cos = prov.get(Key.CosBy.name, COS_NAME);
/*     */     
/*  78 */     Map<String, Object> attrs = new HashMap();
/*     */     
/*  80 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "foo");
/*  81 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "+bar");
/*  82 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "!bar");
/*  83 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "foobar");
/*     */     
/*  85 */     prov.modifyAttrs(cos, attrs);
/*     */     
/*  87 */     Set<String> getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*  88 */     Assert.assertEquals(3L, getAttrs.size());
/*     */     
/*  90 */     Assert.assertTrue(getAttrs.contains("+foo"));
/*     */     
/*  92 */     Assert.assertTrue((getAttrs.contains("+bar")) || (getAttrs.contains("!bar")));
/*     */     
/*     */ 
/*  95 */     Assert.assertTrue(getAttrs.contains("+foobar"));
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testDelete() throws Exception {
/* 100 */     Cos cos = prov.get(Key.CosBy.name, COS_NAME);
/*     */     
/* 102 */     Map<String, Object> attrs = new HashMap();
/*     */     
/*     */ 
/* 105 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "foo");
/* 106 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "-bar");
/* 107 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "!foobar");
/*     */     
/* 109 */     prov.modifyAttrs(cos, attrs);
/* 110 */     Set<String> getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/* 112 */     Assert.assertEquals(3L, getAttrs.size());
/* 113 */     Assert.assertTrue((getAttrs.contains("+foo")) && (getAttrs.contains("-bar")) && (getAttrs.contains("!foobar")));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 120 */     attrs.clear();
/* 121 */     StringUtil.addToMultiMap(attrs, "-zimbraZimletAvailableZimlets", "+foo");
/* 122 */     prov.modifyAttrs(cos, attrs);
/* 123 */     getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/* 125 */     Assert.assertEquals(2L, getAttrs.size());
/* 126 */     Assert.assertTrue((getAttrs.contains("-bar")) && (getAttrs.contains("!foobar")));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 132 */     attrs.clear();
/* 133 */     StringUtil.addToMultiMap(attrs, "-zimbraZimletAvailableZimlets", "bar");
/* 134 */     prov.modifyAttrs(cos, attrs);
/* 135 */     getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/* 137 */     Assert.assertEquals(1L, getAttrs.size());
/* 138 */     Assert.assertTrue(getAttrs.contains("!foobar"));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 143 */     attrs.clear();
/* 144 */     StringUtil.addToMultiMap(attrs, "-zimbraZimletAvailableZimlets", "-foobar");
/* 145 */     prov.modifyAttrs(cos, attrs);
/* 146 */     getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/* 148 */     Assert.assertEquals(1L, getAttrs.size());
/* 149 */     Assert.assertTrue(getAttrs.contains("!foobar"));
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testAdd() throws Exception
/*     */   {
/* 155 */     Cos cos = prov.get(Key.CosBy.name, COS_NAME);
/*     */     
/* 157 */     Map<String, Object> attrs = new HashMap();
/*     */     
/*     */ 
/* 160 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "foo");
/* 161 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "-bar");
/* 162 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "!foobar");
/*     */     
/* 164 */     prov.modifyAttrs(cos, attrs);
/* 165 */     Set<String> getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/* 167 */     Assert.assertEquals(3L, getAttrs.size());
/* 168 */     Assert.assertTrue((getAttrs.contains("+foo")) && (getAttrs.contains("-bar")) && (getAttrs.contains("!foobar")));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 175 */     attrs.clear();
/* 176 */     StringUtil.addToMultiMap(attrs, "+zimbraZimletAvailableZimlets", "white");
/* 177 */     prov.modifyAttrs(cos, attrs);
/* 178 */     getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/* 180 */     Assert.assertEquals(4L, getAttrs.size());
/* 181 */     Assert.assertTrue((getAttrs.contains("+foo")) && (getAttrs.contains("-bar")) && (getAttrs.contains("!foobar")) && (getAttrs.contains("+white")));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 190 */     attrs.clear();
/* 191 */     StringUtil.addToMultiMap(attrs, "+zimbraZimletAvailableZimlets", "-foo");
/* 192 */     prov.modifyAttrs(cos, attrs);
/* 193 */     getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/* 195 */     Assert.assertEquals(4L, getAttrs.size());
/* 196 */     Assert.assertTrue((getAttrs.contains("-foo")) && (getAttrs.contains("-bar")) && (getAttrs.contains("!foobar")) && (getAttrs.contains("+white")));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 204 */     attrs.clear();
/* 205 */     StringUtil.addToMultiMap(attrs, "+zimbraZimletAvailableZimlets", "!foo");
/* 206 */     StringUtil.addToMultiMap(attrs, "+zimbraZimletAvailableZimlets", "+foo");
/* 207 */     prov.modifyAttrs(cos, attrs);
/* 208 */     getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/* 210 */     Assert.assertEquals(4L, getAttrs.size());
/* 211 */     Assert.assertTrue(((getAttrs.contains("!foo")) || (getAttrs.contains("+foo"))) && (getAttrs.contains("-bar")) && (getAttrs.contains("!foobar")) && (getAttrs.contains("+white")));
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   @Test
/*     */   public void testDeleteAdd()
/*     */     throws Exception
/*     */   {
/* 220 */     Cos cos = prov.get(Key.CosBy.name, COS_NAME);
/*     */     
/* 222 */     Map<String, Object> attrs = new HashMap();
/*     */     
/*     */ 
/* 225 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "foo");
/* 226 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "-bar");
/* 227 */     StringUtil.addToMultiMap(attrs, "zimbraZimletAvailableZimlets", "!foobar");
/*     */     
/* 229 */     prov.modifyAttrs(cos, attrs);
/* 230 */     Set<String> getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/* 232 */     Assert.assertEquals(3L, getAttrs.size());
/* 233 */     Assert.assertTrue((getAttrs.contains("+foo")) && (getAttrs.contains("-bar")) && (getAttrs.contains("!foobar")));
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 240 */     attrs.clear();
/* 241 */     StringUtil.addToMultiMap(attrs, "+zimbraZimletAvailableZimlets", "!foo");
/* 242 */     StringUtil.addToMultiMap(attrs, "+zimbraZimletAvailableZimlets", "+bar");
/* 243 */     StringUtil.addToMultiMap(attrs, "-zimbraZimletAvailableZimlets", "bar");
/*     */     
/* 245 */     prov.modifyAttrs(cos, attrs);
/* 246 */     getAttrs = cos.getMultiAttrSet("zimbraZimletAvailableZimlets");
/*     */     
/* 248 */     Assert.assertEquals(3L, getAttrs.size());
/* 249 */     Assert.assertTrue((getAttrs.contains("!foo")) && (getAttrs.contains("+bar")) && (getAttrs.contains("!foobar")));
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/prov/ldap/TestProvCallbackAvailableZimlets.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */